<?php

/**
 * This is the model class for table "{{ord_cmpinfo}}".
 *
 * The followings are the available columns in table '{{ord_cmpinfo}}':
 * @property integer $zon_id
 * @property integer $zm_id
 * @property string $zon_title
 * @property string $zon_code
 * @property string $zon_address
 * @property string $zon_tel
 * @property string $zon_bank
 * @property string $zon_bankcode
 * @property string $zon_pic
 * @property integer $inputtime
 */
class OrdCmpinfo extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return OrdCmpinfo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{ord_cmpinfo}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zm_id, inputtime', 'numerical', 'integerOnly'=>true),
			array('zon_title', 'length', 'max'=>100),
			array('zon_code, zon_bank', 'length', 'max'=>50),
			array('zon_address', 'length', 'max'=>255),
			array('zon_tel, zon_bankcode', 'length', 'max'=>20),
			array('zon_pic', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zon_id, zm_id, zon_title, zon_code, zon_address, zon_tel, zon_bank, zon_bankcode, zon_pic, inputtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zon_id' => 'Zon',
			'zm_id' => 'Zm',
			'zon_title' => 'Zon Title',
			'zon_code' => 'Zon Code',
			'zon_address' => 'Zon Address',
			'zon_tel' => 'Zon Tel',
			'zon_bank' => 'Zon Bank',
			'zon_bankcode' => 'Zon Bankcode',
			'zon_pic' => 'Zon Pic',
			'inputtime' => 'Inputtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zon_id',$this->zon_id);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zon_title',$this->zon_title,true);
		$criteria->compare('zon_code',$this->zon_code,true);
		$criteria->compare('zon_address',$this->zon_address,true);
		$criteria->compare('zon_tel',$this->zon_tel,true);
		$criteria->compare('zon_bank',$this->zon_bank,true);
		$criteria->compare('zon_bankcode',$this->zon_bankcode,true);
		$criteria->compare('zon_pic',$this->zon_pic,true);
		$criteria->compare('inputtime',$this->inputtime);

		$criteria->order = " inputtime DESC ";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}